package com.yango.oss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Li.Ding.yin
 * @create 2021年07月23日22:24-星期五
 * @role 工具类-读取配置文件信息
 */
@Component//交给spring管理
public class ReadPropertiesUtil implements InitializingBean {

    //声明变量
    @Value("${aliyun.oss.file.endpoint}")
    private String endpoint;//地域节点

    @Value("${aliyun.oss.file.keyid}")
    private String keyid;//key_id

    @Value("${aliyun.oss.file.keysecret}")
    private String keysecret;//秘钥

    @Value("${aliyun.oss.file.bucketname}")
    private String bucketname;//bucketname列表

    //声明常量，用于赋值
    public static String ENDPOINT;
    public static String KEYID;
    public static String KEYSECRET;
    public static String BUCKETNAME;

    //赋值
    @Override
    public void afterPropertiesSet() throws Exception {
        //赋值
        ENDPOINT = endpoint;
        KEYID = keyid;
        KEYSECRET = keysecret;
        BUCKETNAME = bucketname;
    }
}
